/*

Author   : chaos

FileName : class_convert2.cpp

Date     : 14/08/17 21:52:24

*/
#include <iostream>
using namespace std;

class Base
{
    public:
        Base():pri_att(1){}
    private:
        int pri_att;
};

class Derived:public Base
{
    public:
        int Derived_att;
        Derived():Derived_att(2){}
};

void class_cast_ptr(Derived * A_Derived)
{
    cout << "A_Derived->Derived_att = " << A_Derived->Derived_att << endl;
}

void class_cast_ref(Derived & A_Derived)
{
    cout << "A_Derived.Derived_att = " << A_Derived.Derived_att << endl;
}

void class_cast_val(Derived A_Derived)
{
    cout << "A_Derived.Derived_att = " << A_Derived.Derived_att << endl;
}

int main(int argc ,char *argv[])
{
    Base * base_ptr = new Derived;

    class_cast_ptr(static_cast<Derived *>(base_ptr));

    Base A_Base;

    class_cast_ref(static_cast<Derived &>(A_Base));

    //class_cast_val(static_cast<Derived>(A_Base));
    return 0;
}
